package com.cryptoneedle.center.source.repository.constraint;


import com.bubbles.engine.data.core.repository.BaseRepository;
import com.cryptoneedle.center.source.entity.constraint.ConstraintCheck;
import com.cryptoneedle.center.source.key.constraint.ConstraintCheckKey;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>description: 源数据源-检查约束 </p>
 *
 * @author CryptoNeedle
 * @date 2025-06-20
 */
@Repository
public interface ConstraintCheckRepository extends BaseRepository<ConstraintCheck, ConstraintCheckKey> {

    @Query("  FROM ConstraintCheck " +
            "WHERE catalogName = :catalogName " +
            "ORDER BY catalogName, databaseName, tableName, constraintName")
    List<ConstraintCheck> constraintChecks(String catalogName);

    @Query("  FROM ConstraintCheck " +
            "WHERE catalogName = :catalogName " +
            "  AND databaseName = :databaseName " +
            "ORDER BY catalogName, databaseName, tableName, constraintName")
    List<ConstraintCheck> constraintChecks(String catalogName, String databaseName);

    @Query("  FROM ConstraintCheck " +
            "WHERE catalogName = :catalogName " +
            "  AND databaseName = :databaseName " +
            "  AND tableName = :tableName " +
            "ORDER BY catalogName, databaseName, tableName, constraintName")
    List<ConstraintCheck> constraintChecks(String catalogName, String databaseName, String tableName);
}